package com.usian.controller;

import com.usian.entity.PageResult;
import com.usian.entity.QueryPageBean;

import com.usian.pojo.Goods;
import com.usian.pojo.Role;
import com.usian.pojo.User;
import com.usian.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    GoodsService goodsService;

    @RequestMapping("/pageList")
    public PageResult pageList(@RequestBody QueryPageBean queryPageBean){
        return goodsService.pageList(queryPageBean);
    }

    @RequestMapping("/showList")
    public List<User> showList(@RequestBody User user){
        return goodsService.showList(user);
    }

    @RequestMapping("/register")
    public void register(@RequestBody User user){
        goodsService.register(user);
    }

    @RequestMapping("/findRole")
    public List<Role> findRole(){
        return goodsService.findRole();
    }

    @RequestMapping("/delete")
    public void delete(@RequestParam Integer id){
        goodsService.delete(id);
    }

    @RequestMapping("/add")
    public void add(@RequestBody Goods goods){
        goodsService.add(goods);
    }

    @RequestMapping("/update")
    public void update(@RequestBody Goods goods){
        goodsService.update(goods);
    }

    @RequestMapping("/updateStatus")
    public void updateStatus(@RequestParam Integer id,@RequestParam Integer status){
        goodsService.updateStatus(id,status);
    }
}
